<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../../js/boot.js"></script>
</head>

<body>
    <div class="layui-fluid">
        <div class="flexrow">
            <div class="layui-panel list-container">
                <div class="list-search-container">
                    <div class="list-search-item">
                        <span>表名称：</span>
                        <input id="table_name" autocomplete="off" class="layui-input">
                    </div>
                    <div class="list-search-item">
                        <span>表描述：</span>
                        <input id="table_comment" autocomplete="off" class="layui-input">
                    </div>
                    <button class="layui-btn layui-btn-sm" style="margin-left:5px" onclick="BindTableData()"><i class="layui-icon layui-icon-search layui-font-12"></i>搜索</button>
                </div>
                <table class="layui-table" lay-data="{id: 'datagrid'}" lay-filter="datagrid">
                    <thead>
                        <tr>
                            <th lay-data="{type:'checkbox'}"></th>
                            <th lay-data="{field:'table_name'}">表名称</th>
                            <th lay-data="{field:'table_comment'}">表描述</th>
                            <th lay-data="{field:'create_time', width:200, align:'center'}">创建时间</th>
                            <th lay-data="{field:'update_time', width:200, align:'center'}">更新时间</th>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>
    <div id="opcontainer">
        <button class="layui-btn" onclick="HandleSave()">确认</button>
        <button class="layui-btn layui-btn-primary" onclick="HandleClose()">关闭</button>
    </div>
</body>
<script>
    $(function() {
        BindTableData();
    })

    function BindTableData() {
        var param = {
            table_name: $("#table_name").val(),
            table_comment: $("#table_comment").val(),
        }
        BindTable("datagrid", "system/codegen/getImportTableList", param);
    }

    function HandleSave() {
        var checkData = GetCheckData();
        if (checkData.length > 0) {
            HttpPost(JSON.stringify(checkData), 'system/codegen/imortTable', function(result) {
                CloseLoading();
                if (result.code == 0) {
                    CloseDialog();
                } else {
                    OpenFail(result.msg);
                }
            })
        } else {
            OpenWarning("未选择数据")
        }
    }


    function HandleClose() {
        CloseDialog();
    }
</script>

</html>